﻿Go
CREATE TABLE [dbo].[FileInformation](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ActualFileName] [varchar](250) NULL,
	[CurrentFileName] [varchar](250) NULL,
	[FileSize] [int] NULL,
	[FileExtension] [varchar](5) NULL,
	[IsActive] [bit] NULL,
	[IsDeleted] [bit] NULL,
	[CreatedBy] [varchar](150) NULL,
	[CreatedDate] [datetime] NULL,
	[UpdatedBy] [varchar](150) NULL,
	[UpdatedDate] [datetime] NULL,
	[IsFolder] [bit] NULL,
	[ParentId] [int] NULL
) ON [PRIMARY]

Go

Alter table [dbo].LogoDetailDetail
add [Id] [int] IDENTITY(1,1) NOT NULL
Go
Alter table [dbo].LogoDetailDetail
add [Scripts] varchar(max) null

Go
Create PROCEDURE [dbo].[SP_FileInformation]
@Id int OUTPUT,
	@ActualFileName varchar(250)
           ,@CurrentFileName varchar(250)
           ,@FileSize int
           ,@FileExtension varchar(5)
           ,@IsActive bit
           ,@IsDeleted bit
           ,@CreatedBy varchar(150)
           ,@CreatedDate datetime
           
           ,@IsFolder bit
           ,@ParentId int
AS
BEGIN
	INSERT INTO [dbo].[FileInformation]
           ([ActualFileName]
           ,[CurrentFileName]
           ,[FileSize]
           ,[FileExtension]
           ,[IsActive]
           ,[IsDeleted]
           ,[CreatedBy]
           ,[CreatedDate]
           ,[IsFolder]
           ,[ParentId])
     VALUES
           (@ActualFileName
           ,@CurrentFileName
           ,@FileSize
           ,@FileExtension
           ,@IsActive
           ,@IsDeleted
           ,@CreatedBy
           ,@CreatedDate
           
           ,@IsFolder
           ,@ParentId)
			SET @Id = SCOPE_IDENTITY()
END
Go

GO
Create PROCEDURE [dbo].[SP_GetFileInformation]
@Id int 
AS
BEGIN
	select * from FileInformation f where f.Id=@Id
           	
END
GO

GO

ALTER PROCEDURE [dbo].[SearchLogoInformation] 
	@CurrentDate DateTime= null,
	@To int,
	@From int,
	@MenuId int = null
AS
BEGIN
select * from (
	select *,Row_Number() over(order by li.CurrentDate desc) as PageNumbers,
	(select count(b.Id) from LogoInformation b
	where b.CurrentDate=isnull(@CurrentDate,b.CurrentDate)
	and b.Id in (select g.LogoInformationId from logoDetail g 
	where g.MenuId =isnull(@MenuId,g.MenuId))) as TotalCount
	
	from LogoInformation li
	where li.CurrentDate=isnull(@CurrentDate,li.CurrentDate)
	and li.Id in (select d.LogoInformationId from logoDetail d 
	
	where d.MenuId =isnull(@MenuId,d.MenuId)
	
	)
	
	) 
	t where t.PageNumbers between @To and @From
	
	
END


Go